package com.yunji.storage.dao.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yunji.common.base.BaseDaoImpl;
import com.yunji.common.utils.bean.BeanUtils;
import com.yunji.storage.bo.DiscardInfoListQueryBO;
import com.yunji.storage.dao.IDiscardInfoDao;
import com.yunji.storage.domain.DiscardInfoDO;
import com.yunji.storage.mapper.DiscardInfoMapper;
import org.springframework.stereotype.Repository;

import java.util.Arrays;
import java.util.List;

@Repository
public class DiscardInfoDaoImpl extends BaseDaoImpl<DiscardInfoMapper, DiscardInfoDO> implements IDiscardInfoDao {
    @Override
    public List<DiscardInfoDO> search(DiscardInfoListQueryBO bo) {
        return list(new LambdaQueryWrapper<DiscardInfoDO>()
                .eq(BeanUtils.isNotNull(bo.getDiscardId()), DiscardInfoDO::getDiscardId, bo.getDiscardId()));
    }

    @Override
    public boolean deleteByDiscardIds(Long... discardIds) {
        return remove(new LambdaQueryWrapper<DiscardInfoDO>()
                .in(DiscardInfoDO::getDiscardId, Arrays.asList(discardIds)));
    }
}
